<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\EnterpriseAdmin
 *
 * @property int $id
 * @property int $enterprise_id 商家id
 * @property int $user_id 管理员id
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\EnterpriseAdmin onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin whereEnterpriseId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\EnterpriseAdmin whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\EnterpriseAdmin withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\EnterpriseAdmin withoutTrashed()
 * @mixin \Eloquent
 */
class EnterpriseAdmin extends Model
{
    protected $table = "enterprise_admin";
    use SoftDeletes;

    public static function getEnterpriseId($userId){
        $data=self::whereUserId($userId)->first();
        return $data ? $data->enterprise_id : 0;
    }

    public static function isEnterpriseAdmin($userId,$enterpriseId){
        $data=self::whereUserId($userId)->whereEnterpriseId($enterpriseId)->first();
        return $data ? true : false;
    }
}
